package com.example.exploitapplication;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;


//动态广播接受
public class MyBroadcastReceiver {


    final String action = "com.zzw";
    BroadcastReceiver mBroadcastReceiver;
    public void initBroadcast(Context context) {
        mBroadcastReceiver = new TestBroadcastReceiver();
        IntentFilter filter = new IntentFilter(action);// 过滤
        context.registerReceiver(mBroadcastReceiver, filter);
    }

    private class TestBroadcastReceiver extends BroadcastReceiver {
        // 接收广播

        @Override
        public void onReceive(Context context, Intent intent) {
            Log.e("exploit 接受广播的状态-----", "动态广播接受成功");
            Log.e("exploit 收到的action-----", intent.getAction());
            Log.e("exploit -------", intent.getExtras().getString("name"));
        }
    }
}
